package com.ciaojian.core.mapper;

import com.ciaojian.core.model.ShareRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 分享记录表 Mapper 接口
 * </p>
 *
 * @author Atlakyn
 * @since 2021-03-31
 */
public interface ShareRecordMapper extends BaseMapper<ShareRecord> {

    /**
     * 查询用户的邀请成功数
     *
     * @param invited 邀请人
     * @return 邀请成功数
     */
    @Select("SELECT count(0) FROM d_share_record WHERE invite_id = #{invited} AND share_id IS NOT NULL")
    Integer countByInvited(@Param("invited") Integer invited);

    /**
     * 查询用户的邀请成功数,裂变活动
     *
     * @param invited 邀请人
     * @return 邀请成功数
     */
    @Select("SELECT count(0) FROM d_share_record WHERE invite_id = #{invited} AND share_id IS NOT NULL and m_id =#{mId}")
    Integer countByInvitedMarketing(@Param("invited") Integer invited,@Param("mId") Integer mid);
}
